package com.atguigu.spring5.service;

import com.atguigu.spring5.dao.UserDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

//@Component("userService")
@Service("userService")
public class UserService {

    @Value("abc牛的一批")
    private String abc;


    //定义dao 的类型属性
    // 不需要添加set 方法
    // 添加注入属性注解
//    @Qualifier("userDaoImpl01")
//    @Autowired
//    private UserDao userDao;

    @Resource(name = "userDaoImpl02")
    private UserDao userDao;

    public void addUser() {
        System.out.println(abc);
        userDao.add();
    }

    public void add() {
        System.out.printf("service add ....");
    }
}
